<!-- 编辑批次Modal -->
<div class="modal fade" id="allot-custom" tabindex="-1">
    <div class="modal-dialog">
        <form id="allot_form" name="allot_form" method="post" action="/custom/index/allot">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" id="batch-title">分配客户</h4>
                </div>
                <div class="modal-body">
                    <div class="org-tree-select-panel">
                        <input name="selected-folder-value" class="selected-folder-value" type="hidden" value="">
                        <input name="selected-member-value" class="selected-member-value" type="hidden" value="">
                        <div class="org-tree-panel">
                            <div id="org_depart" class="org-tree-radio">
                                <volist name="depart_tree" id="depart">
                                    <ul class="org-tree">
                                        <li data-type="department">
                                            <div class="item item-folder expand" data-value="{$depart.name}">
                                                <a class="caret-icon more" role="button"><i class="icon-arrow fa fa-caret-down"></i></a>
                                                <a class="item-name" role="button">
                                                    <i class="icon-folder fa fa-folder-open-o"></i>
                                                    <i class="icon-check fa fa-square-o" style="display:none;"></i>
                                                    <span class="name" data-id="{$depart.id}">{$depart.name}</span>
                                                </a>
                                            </div>
                                            <ul class="expand">
                                                <volist name="depart._child" id="depart2">

                                                    <li data-type="department">
                                                        <div class="item item-folder expand" data-value="{$depart2.name}">
                                                            <a class="caret-icon more" role="button"><i class="icon-arrow fa fa-caret-down"></i></a>
                                                            <a class="item-name" role="button">
                                                                <i class="icon-folder fa fa-folder-open-o"></i>
                                                                <i class="icon-check fa fa-square-o" style="display:none;"></i>
                                                                <span class="name" data-id="{$depart2.id}">{$depart2.name}</span>
                                                            </a>
                                                        </div>
                                                        <ul class="expand">
                                                            <volist name="depart2.sys_user" id="member2">

                                                                <li data-type="member">
                                                                    <div class="item expand" data-value="{$member2.id}">
                                                                        <a class="item-name" role="button">
                                                                            <i class="icon-folder fa fa-user"></i>
                                                                            <i class="icon-check fa fa-square-o"></i>
                                                                            <span class="name">{$member2.name}</span>
                                                                        </a>
                                                                    </div>
                                                                </li>

                                                            </volist>
                                                        </ul>
                                                    </li>
                                                </volist>
                                            </ul>
                                        </li>
                                        <!--<volist name="depart.sys_user" id="member">-->
                                        <!--<if condition="$member['role'] lt 3">-->
                                        <!--<li data-type="member">-->
                                        <!--<div class="item expand" data-value="{$member.id}">-->
                                        <!--<a class="item-name" role="button">-->
                                        <!--<i class="icon-folder fa fa-user"></i>-->
                                        <!--<i class="icon-check fa fa-square-o"></i>-->
                                        <!--<span class="name">{$member.name}</span>-->
                                        <!--</a>-->
                                        <!--</div>-->
                                        <!--</li>-->
                                        <!--</if>-->
                                        <!--</volist>-->
                                    </ul>
                                </volist>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary" id="allot_custom">分配</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $('[data-toggle="modal"][data-target="#allot-form-custom"]').click(function () {
//            reset_allot_form();

//            var $this = $(this);
//            var node = $this.parent().parent();
//            edit_edit_form(node);
        });

        $("#allot_form").validate({
            submitHandler: function () {
                if ($("#customids").val() == '') {
                    alertify.alert("请选择要分配的客户!");
                    return false;
                }
                if ($(".selected-member-value").val() == '') {
                    alertify.alert("请选择要分配的人员!");
                    return false;
                }
                var postdata = $("#allot_form").serialize() + "&customids=" + $("#customids").val();
                $.post($("#allot_form").attr("action"), postdata, function (data) {
                    if (data === "0") {
                        alertify.alert("分配成功!", function () {
                            $('#allot_form-custom').modal('hide');
                            location.reload();
                        });
                    } else {
                        alertify.alert(data);
                    }
                }).error(function (msg, url, line) {
                    alert(msg.responseText);
                });
            },
            ignore: "",
            rules: {},
            messages: {}
        });

    });

</script>